// Forms.less
// Base styles for various input types, form layouts, and states
// -------------------------------------------------------------


// Form controls
// -------------------------

// Shared size and type resets
select,
textarea,
input[type="text"],
input[type="password"],
input[type="datetime"],
input[type="datetime-local"],
input[type="date"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
input[type="color"],
.uneditable-input {
  padding: 4px 8px;
}

// Reset appearance properties for textual inputs and textarea
// Declare width for legacy (can't be on input[type=*] selectors or it's too specific)
input,
textarea {
  width: 210px;
}
// Reset height since textareas have rows
textarea {
  padding-right: 4px;
}
// Everything else
textarea,
input[type="text"],
input[type="password"],
input[type="datetime"],
input[type="datetime-local"],
input[type="date"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
input[type="color"],
.uneditable-input {
  border: 1px solid #d9d9d9;
  border-top: 1px solid #c0c0c0;
  .border-radius(@inputBorderRadius);
  .box-shadow(none);
  .transition(none);

  &:hover {
    border: 1px solid #b9b9b9;
    border-top: 1px solid #a0a0a0;
    .box-shadow(inset 0 1px 2px rgba(0,0,0,0.1));
    z-index: 2;
  }

  // Focus state
  &:focus,
  &.focused {
    outline: none;
    border: 1px solid #4d90fe;
    .transition(none);
    .box-shadow(inset 0 1px 2px rgba(0,0,0,0.3));
  }
}


// CHECKBOXES & RADIOS
// -------------------

// Google style
input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  background: white;
  border: 1px solid #dcdcdc;
  .border-radius(1px);
  .box-sizing(border-box);
  position: relative;
  
  // override styles for IE
  box-sizing: content-box e("\9");
  width: 16px e("\9");
  height: 16px e("\9");
  border-width: 0 e("\9");
}
input[type="radio"] {
  .border-radius(1em);
  width: 15px;
  height: 15px;
}
input[type="checkbox"]:hover {
  border-color: #c6c6c6;
  .box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.1));
  
  // no box shadow for IE
  box-shadow: none e("\9");
}
input[type="checkbox"]:active,
input[type="radio"]:active {
  border-color: #c6c6c6;
  background-color: #ebebeb;
  // override the bkgd color for IE
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffffffff', GradientType=0);
}
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: #fff;
}
input[type="checkbox"]:checked::after {
  content: url(../img/checkmark.png);
  display: block;
  position: absolute;
  top: -6px;
  left: -5px;
}
input[type="radio"]:checked::after {
  content: '';
  display: block;
  position: relative;
  top: 3px;
  left: 3px;
  width: 7px;
  height: 7px;
  background: #666;
  .border-radius(1em);
}
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: none;
  border-color: #4d90fe;
}


// DISABLED STATE
// --------------

// Disabled and read-only inputs
input[disabled],
select[disabled],
textarea[disabled] {
  cursor: not-allowed;
  border: 1px solid #e5e5e5;
  background: #f1f1f1;

  &:hover {
    .box-shadow(none);
  }
}
input[readonly],
select[readonly],
textarea[readonly] {
  cursor: not-allowed;
  border: 1px solid #d9d9d9;

  &:hover,
  &:focus {
    .box-shadow(none);
  }
}


// INPUT GROUPS
// ------------

.input-prepend {
  input,
  select,
  .uneditable-input {
    .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
  }
}

.input-append {
  input,
  select,
  .uneditable-input {
    .border-radius(@inputBorderRadius 0 0 @inputBorderRadius);
  }
}

// Remove all border-radius for inputs with both prepend and append
.input-prepend.input-append {
  input,
  select,
  .uneditable-input {
    .border-radius(0);
  }
}


// FORM FIELD FEEDBACK STATES
// --------------------------

// HTML5 invalid states
// Shares styles with the .control-group.error above
input:focus:required:invalid,
textarea:focus:required:invalid,
select:focus:required:invalid {
  color: #b94a48;
  border-color: #ee5f5b;
  &:focus {
    border-color: #4d90fe;
    .box-shadow(0);
  }
}


// HORIZONTAL & VERTICAL FORMS
// ---------------------------

// Common properties
// -----------------

.form-search,
.form-inline,
.form-horizontal {
  input,
  textarea,
  select,
  .help-inline,
  .uneditable-input,
  .input-prepend,
  .input-append {
    display: inline-block;
    .ie7-inline-block();
    margin-bottom: 0;
  }
  // Re-hide hidden elements due to specifity
  .hide {
    display: none;
  }
}